package com.ejd.web.vo.genl;

import java.util.List;



import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.SelectItem;


import com.ejd.service.ISizeService;
import com.ejd.utils.SpringFacesUtil;
import com.ejd.web.bo.impl.Size;
import com.ejd.web.constant.SpringBeanConstants;

@ManagedBean(name="existSize")
@RequestScoped
public class ExistSizeBean implements java.io.Serializable {

	private SelectItem[] sizeItems;

	public SelectItem[] getSizeItems() {
		return sizeItems;
	}

	public void setSizeItems(SelectItem[] sizeItems) {
		this.sizeItems = sizeItems;
	}
	public ExistSizeBean() {
		
		ISizeService<Size,Long> sizeService = (ISizeService<Size,Long>)SpringFacesUtil.getSpringBean(SpringBeanConstants.SIZE_SERVICE_BEAN_NAME);
		sizeService.setEntityClass(Size.class);
		sizeService.setPKClass(Long.class);
		List<Size> sizes = sizeService.getAll();
		SelectItem[] tempSizeItems = new SelectItem[sizes.size()];
		if (null != sizes && !(sizes.isEmpty())) {
			for (int i=0; i< tempSizeItems.length; i++) {
				Size size = (Size) sizes.get(i);
				tempSizeItems[i] = new SelectItem(new Long(size.getSizeId()),size.getSizeName());
			}
		}
		this.setSizeItems(tempSizeItems);
	}
}
